package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.business.domain.FeeSchedules;
import com.elder.business.service.IFeeSchedulesService;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 缴费信息Controller
 * 
 * @author elder
 * @date 2023-11-26
 */
@RestController
@RequestMapping("/business/schedules")
public class FeeSchedulesController extends BaseController
{
    @Autowired
    private IFeeSchedulesService feeSchedulesService;

    /**
     * 查询缴费信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:schedules:list')")
    @GetMapping("/list")
    public TableDataInfo list(FeeSchedules feeSchedules)
    {
        startPage();
        List<FeeSchedules> list = feeSchedulesService.selectFeeSchedulesList(feeSchedules);
        return getDataTable(list);
    }

    /**
     * 导出缴费信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:schedules:export')")
    @Log(title = "缴费信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeeSchedules feeSchedules)
    {
        List<FeeSchedules> list = feeSchedulesService.selectFeeSchedulesList(feeSchedules);
        ExcelUtil<FeeSchedules> util = new ExcelUtil<FeeSchedules>(FeeSchedules.class);
        util.exportExcel(response, list, "缴费信息数据");
    }

    /**
     * 获取缴费信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:schedules:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(feeSchedulesService.selectFeeSchedulesById(id));
    }

    /**
     * 新增缴费信息
     */
    @PreAuthorize("@ss.hasPermi('business:schedules:add')")
    @Log(title = "缴费信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeeSchedules feeSchedules)
    {
        return toAjax(feeSchedulesService.insertFeeSchedules(feeSchedules));
    }

    /**
     * 修改缴费信息
     */
    @PreAuthorize("@ss.hasPermi('business:schedules:edit')")
    @Log(title = "缴费信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeeSchedules feeSchedules)
    {
        return toAjax(feeSchedulesService.updateFeeSchedules(feeSchedules));
    }

    /**
     * 删除缴费信息
     */
    @PreAuthorize("@ss.hasPermi('business:schedules:remove')")
    @Log(title = "缴费信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(feeSchedulesService.deleteFeeSchedulesByIds(ids));
    }
}
